#!/bin/bash
echo "🚀 Building Modern AI Agent System (Fixed Find Issue)..."
echo

WXWIN="/d/vc/wxWidgets-3.2.7"

# 检查必要的源文件
echo "📋 Checking source files..."
for file in "src/ai_agent.h" "src/agents.h" "src/ai_agent.cpp" "src/agents.cpp" "src/modern_chat_app.h" "src/modern_chat_app.cpp"; do
    if [[ ! -f "$file" ]]; then
        echo "❌ Missing: $file"
        exit 1
    fi
done
echo "✅ All source files present"

# Build agent system
echo "🔨 Building AI Agent System..."
g++ -std=c++17 -O2 -Wall -Wextra \
    -I"$WXWIN/include" \
    -I"$WXWIN/lib/wx/include/msw-unicode-3.2" \
    -D__WXMSW__ -D_UNICODE -DUNICODE \
    src/ai_agent.cpp \
    src/agents.cpp \
    src/modern_chat_app.cpp \
    -L"$WXWIN/lib" \
    -lwxmsw32u_core_gcc_custom -lwxbase32u_gcc_custom \
    -lwxmsw32u_adv_gcc_custom \
    -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 \
    -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid \
    -lcomctl32 -lrpcrt4 -loleacc -luxtheme \
    -o modern_ai_chat.exe

if [[ $? -eq 0 ]]; then
    echo "✅ Modern AI system built: modern_ai_chat.exe"
    echo ""
    echo "🎉 构建成功！"
    echo "📁 输出文件: modern_ai_chat.exe"
    echo ""
    echo "🚀 运行命令: ./modern_ai_chat.exe"
else
    echo "❌ Build failed"
    exit 1
fi
